package com.bsj.media.media.resample.basic;


import com.bsj.media.media.resample.resamplerState;

public abstract class resamplerBasic {

	public abstract int getType();

	public abstract int resampler_basic_func(resamplerState st, int channel_index, final float[] in, final int offset_in, int in_len,
											 float[] out, int out_len);

	public void cubic_coef(float frac, float[] interp) {
		/*
		 * Compute interpolation coefficients. I'm not sure whether this corresponds to
		 * cubic interpolation but I know it's MMSE-optimal on a sinc
		 */
		interp[0] = -0.16667f * frac + 0.16667f * frac * frac * frac;
		interp[1] = frac + 0.5f * frac * frac - 0.5f * frac * frac * frac;
		interp[3] = -0.33333f * frac + 0.5f * frac * frac - 0.16667f * frac * frac * frac;
		/* Just to make sure we don't have rounding problems */
		interp[2] = (float) (1.0 - interp[0] - interp[1] - interp[3]);
	}

	public double MULT16_16(float a, float b) {
		return ((double) (a) * (float) (b));
	}

	public float MULT16_32_Q15(float a, float b) {
		return ((a) * (b));
	}
}
